﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.IO;
using GameEngine.Model.Data;

namespace ExampleSilverlight
{
    public partial class MainMenuUC : UserControl
    {
        public MainMenuUC()
        {
            InitializeComponent();
        }

        private void NewButton_Click(object sender, RoutedEventArgs e)
        {
            MyFacade.Instance.LoadGame(null);
        }

        private void LoadButton_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            if (ofd.ShowDialog().Value)
            {
                TextReader w = new StreamReader(ofd.File.OpenRead());
                string gameSerialized = w.ReadToEnd();
                w.Close();
                var game = new GameVO<int>();
                game.DeSerialize(gameSerialized);

                MyFacade.Instance.LoadGame(game);
            }
        }
    }
}
